home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / graphics / scrfe100.zip / FONTOOLS.ASM < prev    next >
Assembly Source File  |  1993-02-27  |  6KB  |  402 lines

  1. ;This is a collection of procedures for loading SFF and SFS files. For details,
  2. ;see documentation. Most interface information, however, is imbedded in this
  3. ;file. The registers to pass pointers to are listed for each procedure. These
  4. ;procedures are all near procedures. 
  5.  
  6. TEXT SEGMENT BYTE PUBLIC
  7. ASSUME CS:TEXT
  8.  
  9. false equ 0
  10. true equ 1
  11. lines200 equ 0; for screen lines
  12. lines350 equ 1
  13. lines400 equ 2
  14.  
  15. vseg dw 0b800h ; video segment
  16. linesperchar db 13 ; points - 1
  17. vga db false
  18. ega db false
  19. vedone db false ; is video system initialized
  20.  
  21. fontheader db '@JLSFF',1 ; header for a font file
  22.  
  23. cmpegafalse proc near ; checks if DETEGA has been called before using EGA 
  24.                       ; variable
  25. cmp byte ptr vedone,false
  26. jne cef
  27. call detega
  28. cef:
  29. cmp byte ptr ega,false
  30. ret
  31. cmpegafalse endp
  32.  
  33. cmpvgafalse proc near
  34. cmp byte ptr vedone,false
  35. jne cvf
  36. call detega
  37. cvf:
  38. cmp byte ptr vga,false
  39. ret
  40. cmpvgafalse endp
  41.  
  42. PUBLIC SEQUENCEFONTS
  43. ; Sequencefonts will set up the fonts so that you can load the bit images into
  44. ; segment 0A000h. Each character occupies 32 bytes, so character 0 would be
  45. ; at A000h:0h, character 1 would be at A000h:0020h, etc. this procedure need
  46. ; not be called by programmers in most cases, but if it is, KEEP IT ON AS 
  47. ; LITTLE TIME AS POSSIBLE. DESEQUENCE FONTS AS SOON AS POSSIBLE TO KEEP THE
  48. ; SCREEN FROM LOOKING "SCREWED UP."
  49. sequencefonts proc near 
  50. call cmpegafalse
  51. je nosequence
  52. push ax
  53. push dx
  54. mov ax,0704h
  55. mov dx,03c4h
  56. out dx,ax
  57. mov dx,03ceh
  58. mov ax,0204h
  59. out dx,ax
  60. mov ax,5
  61. out dx,ax
  62. mov ax,0406h
  63. out dx,ax
  64. mov ax,0402h
  65. mov dx,03c4h
  66. out dx,ax
  67. pop dx
  68. pop ax
  69. nosequence:
  70. ret
  71. sequencefonts endp
  72.  
  73. PUBLIC DESEQUENCEFONTS
  74. ;This will normalize the video system from SEQUENCE FONTS.
  75. desequencefonts proc near
  76. call cmpegafalse
  77. je nodesequence
  78. push ax
  79. push dx
  80. mov dx,03c4h
  81. mov ax,0302h
  82. out dx,ax
  83. mov ax,0304h
  84. out dx,ax
  85. mov dx,03ceh
  86. mov ax,4
  87. out dx,ax
  88. mov ax,01005h
  89. out dx,ax
  90. mov ax,0e06h
  91. cmp vseg,0b000h
  92. jne d1
  93. mov ax,0606h
  94. d1:
  95. out dx,ax
  96. pop dx
  97. pop ax
  98. nodesequence:
  99. ret
  100. desequencefonts endp
  101.  
  102. PUBLIC SETSCANLINES
  103. ;SETSCANLINES sets the scanlines on a VGA monitor. Set AL.
  104. setscanlines proc near ; number of scanlines as parameter
  105.  ; IN AL REGISTER
  106.  ; 0=200 lines  1 = 350 lines  2 = 400 lines
  107. jmp ssl
  108. scnlns db 0
  109. ssl:
  110. push ax
  111. push bx
  112. push cx
  113. mov scnlns,al
  114. cmp al,2
  115. ja nossl
  116. call cmpvgafalse
  117. je nossl
  118. mov al,scnlns
  119. mov ah,012h
  120. mov bx,030h
  121. int 010h
  122. mov ax,083h   ; set mode with no video memory clearing
  123. cmp vseg,0b000h
  124. jne s1
  125. mov ax,087h
  126. s1:
  127. int 010h
  128. mov cx,0c0dh
  129. mov al,scnlns
  130. cmp al,0
  131. jne s2
  132. mov cx,0708h
  133. s2:
  134. mov ax,0100h
  135. int 010h
  136. nossl:
  137. pop cx
  138. pop bx
  139. pop ax
  140. ret
  141. setscanlines endp
  142.  
  143. ; Sets character points according to linesperchar
  144. setlinesperchar proc near
  145. call cmpegafalse
  146. je noslpc
  147. push ax
  148. push bx
  149. push cx
  150. push dx
  151. mov ax,01100h
  152. mov bh,linesperchar
  153. inc bh
  154. xor bl,bl
  155. xor cx,cx
  156. xor dx,dx
  157. int 010h
  158. pop dx
  159. pop cx
  160. pop bx
  161. pop ax
  162. noslpc:
  163. ret
  164. setlinesperchar endp
  165.  
  166. comparestrings proc near ; compares DS:SI & ES:DI and increments SI & DI
  167.  ; does for CX bytes sets carry flag
  168. cstr:
  169. repe cmpsb
  170. ret
  171. comparestrings endp
  172.  
  173. PUBLIC READFONT
  174. ; READS font in memory. Set DS:SI to buffer
  175. readfont proc near ; FAR pointer to DS:SI
  176. call cmpegafalse
  177. jne rf1
  178. jmp norf
  179. numberofentries db 0
  180. i dw 0
  181. j dw 0
  182. k dw 0
  183. begchar dw 0
  184. endchar dw 0
  185. rf1:
  186. mov di,seg fontheader
  187. mov es,di
  188. mov di,offset fontheader
  189. mov cx,7
  190. call comparestrings
  191. je goon1
  192. jmp norf
  193. goon1:
  194. xor ax,ax
  195. lodsb
  196. push ax
  197. call setscanlines
  198. pop ax
  199. lodsb
  200. mov linesperchar,al
  201. cmp al,16
  202. jb goon2
  203. jmp norf
  204. goon2:
  205. call setlinesperchar
  206. lodsb
  207. mov numberofentries,al
  208. mov i,0
  209. f2:
  210. lodsb
  211. xor ah,ah
  212. mov begchar,ax
  213. lodsb
  214. mov endchar,ax
  215.  
  216. mov ax,begchar
  217. mov j,ax
  218. f1:
  219. call sequencefonts
  220. mov di,0a000h
  221. mov es,di
  222. mov bx,j
  223. mov di,bx
  224. mov cl,5
  225. shl di,cl
  226. mov cl,linesperchar
  227. inc cl
  228. xor ch,ch
  229. shr cl,1
  230. rep movsw
  231. call desequencefonts
  232. inc j
  233. mov ax,endchar
  234. cmp j,ax
  235. jbe f1
  236. inc i
  237. mov al,numberofentries
  238. xor ah,ah
  239. cmp i,ax
  240. jbe f2
  241. norf:
  242. ret
  243. readfont endp
  244.  
  245. PUBLIC READSCREEN
  246. ; Reads screen or block of one from a memory location in DS:SI
  247. readscreen proc near ; FAR pointer must be passed in DS:SI
  248. jmp rs1
  249. xy db 0 
  250. x1 db 1
  251. y1 db 1
  252. x2 db 80
  253. y2 db 25
  254. rs1:
  255. lodsb
  256. mov x1,al
  257. lodsb
  258. mov y1,al
  259. lodsb
  260. mov x2,al
  261. lodsb
  262. mov y2,al
  263. mov al,y1
  264. mov xy,al
  265. r1:
  266. mov cl,x2
  267. inc cl
  268. mov ch,x1
  269. sub cl,ch
  270. xor ch,ch
  271. shl cx,1
  272. mov ax,0b800h
  273. mov es,ax
  274. mov al,xy
  275. dec al
  276. mov ah,0
  277. mov bl,80
  278. mul bl
  279. mov bl,x1
  280. dec bl
  281. xor bh,bh
  282. add bx,ax
  283. shl bx,1
  284. mov di,bx
  285. r2:
  286. lodsb
  287. stosb
  288. loop r2
  289. inc xy
  290. mov al,y2
  291. cmp xy,al
  292. jbe r1
  293. ret 
  294. readscreen endp
  295.  
  296. EGAGrfx proc near ; index in al , value in ah
  297. push dx
  298. mov dx,03ceh
  299. out dx,al
  300. inc dx
  301. mov al,ah
  302. out dx,al
  303. pop dx
  304. ret
  305. EGAgrfx endp
  306.  
  307. detEGA proc near ; sets EGA, VGA, and VSEG variables
  308. mov vedone,true
  309. jmp dega
  310. testmask db 1
  311. BIOSbyte db 0
  312. dega:
  313. xor ax,ax
  314. mov es,ax
  315. mov vseg,0b800h
  316. mov bx,0410h
  317. mov al,es:[bx]
  318. and al,48
  319. cmp al,48
  320. jne deg2
  321. mov vseg,0b000h
  322. deg2:
  323. mov bx,0487h
  324. mov al,es:[bx]
  325. mov biosbyte,al
  326. mov ah,012h
  327. mov bx,0ff10h
  328. int 010h
  329. mov al,biosbyte
  330. and al,060h
  331. mov cl,5
  332. shr al,cl
  333. cmp bl,al
  334. je degcont
  335. cmp bh,0ffh
  336. jne degcont
  337. mov ega,false
  338. jmp degend
  339. degcont:
  340. mov ah,testmask
  341. mov al,8
  342. call EGAGrfx
  343. mov dx,03ceh
  344. mov al,8
  345. out dx,al
  346. mov vga,false
  347. mov dx,03cfh
  348. in al,dx
  349. cmp al,testmask
  350. jne eg1
  351. mov vga,true
  352. eg1:
  353. mov ax,0ff08h
  354. call egagrfx
  355. mov EGA,true
  356. degend:
  357. ret
  358. detega endp
  359.  
  360. PUBLIC SAVEFONTS
  361. ; Saves the state of the fonts
  362. savefonts proc near ; pass on FAR pointer 8192 bytes, ES:DI
  363. call sequencefonts
  364. mov si,0a000h
  365. mov ds,si
  366. xor si,si
  367. mov cx,4096
  368. rep movsw
  369. call desequencefonts
  370. ret
  371. savefonts endp
  372.  
  373. PUBLIC RESTOREFONTS
  374. ; Retrieves the state of the fonts
  375. restorefonts proc near ; pass on FAR pointer - 8192 bytes DS:SI
  376. call sequencefonts
  377. mov di,0a000h
  378. mov es,di
  379. xor di,di
  380. mov cx,4096
  381. rep movsw
  382. call desequencefonts
  383. ret
  384. restorefonts endp
  385.  
  386. PUBLIC RESETFONTS
  387. ; Makes a mode set and resets the scanlines if VGA
  388. resetfonts proc near
  389. push ax
  390. mov ax,083h
  391. int 010h
  392. mov al,2
  393. push ax
  394. call setscanlines
  395. pop ax
  396. pop ax
  397. ret
  398. resetfonts endp 
  399.  
  400. TEXT ENDS
  401. END
  402.